package com.hxm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxm.pojo.entity.Student;
import com.hxm.pojo.until.Result;
import com.hxm.pojo.vo.StudentVo;
import com.hxm.service.StudentService;
import com.hxm.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author MI
* @description 针对表【student】的数据库操作Service实现
* @createDate 2023-04-12 19:31:10
*/
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student>
    implements StudentService{

@Autowired
private  StudentMapper studentMapper;
    @Override
    public Result findByPage(Integer current, Integer pageSize, StudentVo studentVo) {
        Page<Student> page = new Page<>(current,pageSize);
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
            if (StringUtils.hasText(studentVo.getName())){
                wrapper.like("name",studentVo.getName());
            }
            /*if (Objects.nonNull(studentVo.getCid())){
                wrapper.eq("cid",studentVo.getCid());
            }
            if (Objects.nonNull(studentVo.getClassno())){
                wrapper.eq("classno",studentVo.getClassno());
            }
            if (Objects.nonNull(studentVo.getMinage())){
                wrapper.ge("age",studentVo.getMinage());
            }
        if (Objects.nonNull(studentVo.getMaxage())){
            wrapper.le("age",studentVo.getMaxage());
        }*/
        studentMapper.findByPage(page,wrapper);
        return  new Result(200,"分页条件查询成功",page);

    }
}




